package zyh.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintStream;
@WebServlet(name = "TestServlet",urlPatterns = {"/ts"})
public class TestServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,java.io.IOException{

        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charSet=utf-8");
        String name=request.getParameter("name");
        String gender=request.getParameter("gender");
        String[] color=request.getParameterValues("color");
        String national=request.getParameter("country");
        PrintStream out=new PrintStream(response.getOutputStream());
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet测试</title");
        out.println("</head>");
        out.println("<body>");
        out.println("您的名字："+name+"<hr/></br>");
        out.println("您的性别："+gender+"<hr/></br>");
        out.println("您最喜欢的颜色：");
//        for(String c : color){
//            out.println(c+" ");
//        }
        out.println("<hr/></br>");
        out.println("您来自国家："+national+"<hr/></br>");
        out.println("</body>");
        out.println("</html>");
    }
}
